﻿using System;
using SouthernLand.Common;
using SouthernLand.Common.BOL.NhaDat;
using SouthernLand.Common.DAL;

namespace SouthernLand.RaoVat
{
    public partial class Detail : BasePage
    {
        public int RaovatID = -1;

        protected void Page_Load(object sender, EventArgs e)
        {
            RaovatID = Globals.GetIntFromQueryString("RaovatID");
            if (RaovatID <= 0)
                Response.Redirect(Globals.ApplicationPath);
            else
            {
                Raovat obj = Raovat.GetRaovatByID(RaovatID);
                Hinh1.ImageUrl = "/Raovat/Image.ashx?Size=M&ImageUrl=" + obj.Hinh1 + "&LoaitinID=" + obj.Loaitin;
                lblTieude.Text = obj.Tieude;
                lblLoaitin.Text = Loaitin.GetTenLoaiTinByID(obj.Loaitin);
                lblLoaiBDS.Text = Categories.GetCateNameByID(obj.CateID);
                lblKhuvuc.Text = TinhThanh.GetTenTinhThanhByID(obj.Tinhthanh) + " -> " +
                                 QuanHuyen.GetTenQuanHuyenByID(obj.Quanhuyen);
                lblDientichDat.Text = obj.DientichDat + " " + Globals.MetVuong();
                lblDientichXD.Text = obj.DientichXD + " " + Globals.MetVuong();
                lblGia.Text = Globals.Gia(obj.Gia, obj.DonVT, obj.GiaTren);
                lblDiachiNha.Text = obj.DiachiNha;

                lblMota.Text = obj.Mota.Trim();
                if (obj.Mota.Trim().Length <= 2)
                    lblMota.Text = "Không có thông tin mô tả";

                // thong tin ve BDS
                lblHuongNha.Text = HuongNha.GetTenHuongNhaByID(obj.HuongNha);
                lblTinhtrangPL.Text = TinhTrangPL.GetTenTinhTrangPLByID(obj.TinhtrangPL);
                lblVitri.Text = obj.Vitri;
                lblSolau.Text = obj.Solau.ToString();
                lblPhongNgu.Text = obj.PhongNgu.ToString();
                lblPhongVS.Text = obj.PhongVS.ToString();

                // thong tin lien he
                lblHoten.Text = obj.Hoten;
                lblDiachi.Text = obj.Diachi;
                lblEmail.Text = obj.Email;
                lblDienthoai.Text = obj.Dienthoai;
                lblDidong.Text = obj.Didong;
                ClassData.ExecuteSQL("Update w4u_Raovat set TotalViews = (TotalViews + 1) Where (RaovatID=" + RaovatID +") ");
            }
        }
    }
}